#pragma once

#include "nocopy.h"
#include <memory>
#include <string>
#include <functional>
#include <vector>
#include "EventLoopThread.h"

class EventLoop;
// #pragma once
// #include "nocopy.h"

// #include <functional>
// #include <string>
// #include <vector>
// #include <memory>

class EventLoop;
class EventLoopThread;
class EventLoopThreadPool : nocopyable
{
public:
    using ThreadInitCallback = std::function<void(EventLoop *)>;
    EventLoopThreadPool(EventLoop *baseLoop, const std::string &nameArg);
    ~EventLoopThreadPool();
    void setThreadNum(int numThreads){numThreads_ = numThreads;}
    void start(const ThreadInitCallback &cb = ThreadInitCallback());
    EventLoop *getNextloop();
    std::vector<EventLoop*> getAllLoops();
    bool started()const{return started_;}
    const std::string name(){return name_;}
private:
    EventLoop *baseLoop_;
    std::string name_;
    bool started_;
    int numThreads_;
    int next_;
    std::vector<std::unique_ptr<EventLoopThread>> threads_;
    std::vector<EventLoop *> loops_;//线程池中一个Thread对应一个Loop
};